#include "key.hpp"
#include "apm32a10x_gpio.h"
#include "stdio.h"
#include "system.h"
static GPIO_T *btkey_port = GPIOC;
static GPIO_PIN_T btkey_pin = GPIO_PIN_8;


bool BTKEY::get(){
    if(GPIO_ReadInputBit(btkey_port,btkey_pin) == 0) return true;
    else return false;
}

static KEY *btkey = nullptr;
KEY *KEY::getInstance(){
    if( btkey == nullptr){
        GPIO_Config_T gpio_configuration;
        System_setPeripheralClockEnable(CLK_GPIOC,TRUE);
        gpio_configuration.pin = btkey_pin;
        gpio_configuration.mode = GPIO_MODE_IN_PU;
        GPIO_Config(btkey_port,&gpio_configuration);   
        btkey = new BTKEY();  
    }

    return btkey;
}

